#include <stdio.h>
#include <math.h>

int is_integer(double in) {
    return ((int) floor(in)) == in;
}

int main(void) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        double result_a = sqrt(pow(b, 2.0) - pow(a, 2.0));
        if (result_a > 0 && is_integer(result_a)) {
            printf("%d\n", (int) result_a);
            continue;
        }
        double result_b = sqrt(pow(a, 2.0) - pow(b, 2.0));
        if (result_b > 0 && is_integer(result_b)) {
            printf("%d\n", (int) result_b);
            continue;
        }
        double result_c = sqrt(pow(a, 2.0) + pow(b, 2.0));
        if (is_integer(result_c)) {
            printf("%d\n", (int) result_c);
            continue;
        }
        printf("None\n");
    }
    return 0;
}
